package main

import (
	"fmt"
	"time"
)

func main() {
	timer := time.NewTimer(time.Second)
	//fatal error: all goroutines are asleep - deadlock!
	// 造成死锁
	/*for true {
		<- timer.C
	}
	*/
	for true {
		fmt.Println(<-timer.C)
		timer.Reset(time.Second)
	}
}
func main_6_16() {
	timer := time.NewTimer(2 * time.Second)
	fmt.Println("当前时间：", time.Now())

	//2s后, 往timer.C写数据， 有数据后，就可以读取
	t := <-timer.C // channel没有数据后阻塞
	fmt.Println("t = ", t)
}
